import 'package:flutter/material.dart';
import 'package:shining_red_star/model/some_thing.dart';

class SomeThingCard extends StatelessWidget {
  final SomeThingInfo someThing;

  const SomeThingCard({
    super.key,
    required this.someThing,
  });

  @override
  Widget build(BuildContext context) {
    String img = someThing.img[0];
    String txt = '${someThing.title} ${someThing.pinYin}';
    return Column(
      children: [
        Expanded(
          child: Stack(
            alignment: AlignmentDirectional.center,
            children: [
              Column(
                children: [
                  Expanded(
                      child: Container(
                    constraints: const BoxConstraints(maxWidth: 600),
                    child: img.startsWith('http')
                        ? Image.network(img, fit: BoxFit.contain)
                        : Image.asset(img.replaceFirst('/', ''),
                            fit: BoxFit.contain),
                  ))
                ],
              ),
              Positioned(
                  left: 0,
                  right: 0,
                  bottom: 0,
                  child: Container(
                    padding: const EdgeInsets.all(12),
                    child: Text(
                      txt,
                      style: TextStyle(
                        fontFamily: 'PinYin',
                        color: Colors.white,
                        height: 1,
                        fontSize: 22,
                        shadows: List.generate(3, (index) {
                          return const Shadow(
                            blurRadius: 1.0,
                            color: Colors.black,
                            offset: Offset(0, 0),
                          );
                        }),
                      ),
                    ),
                  ))
            ],
          ),
        )
      ],
    );
  }
}
